package com.lanou3g.code0427.study;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

/**
 * If there are no bugs, it was created by Chen FengYao on 2018/4/27;
 * Otherwise, I don't know who created it either
 */

public class Main {
    public static void main(String[] args) {
        Properties properties = new Properties();
        FileInputStream fis = null;
        try {
            fis = new FileInputStream(
                    "test.properties");
            //建立起 配置对象和配置文件的联系
            properties.load(fis);

            // 通过 配置文件中的KEY 来 拿到VALUE
            String username
                    = properties.getProperty("username");
            String password
                     = properties.getProperty("password");

            System.out.println(username + "-" + password);

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (fis != null){
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
